package com.wangxue.stock.config;

import com.wangxue.stock.utils.IdWorker;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author 86198
 * @Date 2022/05/18
 * 定义公共配置类
 */
@Configuration
public class CommonConfig {
    /**
     * 配置id生成器bean
     * 可用于生成一个唯一id全局标识，验证码
     * @return IdWorker
     * @author wangxue
     * @Date 2022/5/19
     */
    @Bean
    public IdWorker idWorker(){
        return new IdWorker();
    }

    /**
     * 密码加密器
     * BCryptPasswordEncoder方法采用SHA-256对密码进行加密
     * @return
     */
    @Bean
    public PasswordEncoder passwordEncoder(){
        return new BCryptPasswordEncoder();
    }
}
